package com.teradata.olingo.processor.core.filter;

import org.apache.olingo.server.api.ODataApplicationException;

import javax.persistence.criteria.Expression;
import javax.persistence.criteria.From;

class GenericAggregationOperationImp implements GenericAggregationOperation {

  private final From<?, ?> root;
  private final GenericOperationConverter converter;

  public GenericAggregationOperationImp(final From<?, ?> root, final GenericOperationConverter converter) {
    this.root = root;
    this.converter = converter;
  }

  /*
   * (non-Javadoc)
   * 
   * @see GenericAggregationOperation#get()
   */
  @Override
  public Object get() throws ODataApplicationException {
    return converter.convert(this);
  }

  @Override
  public GenericFilterAggregationType getAggregation() {
    return GenericFilterAggregationType.COUNT;
  }

  Expression<?> getPath() {
    return root;
  }

}
